﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Metal.Config;

namespace Gui.Controls
{
    public partial class MetalLabel : Label
    {
        /// <summary> Our font object </summary>
        private System.Drawing.Text.PrivateFontCollection pfc;

        public MetalLabel()
        {
            InitializeComponent();
        }

        public void SetFont(string fontName, int fontSize, System.Drawing.FontStyle fontStyle)
        {
            // Load font from file
            this.pfc = new System.Drawing.Text.PrivateFontCollection();

            this.pfc.AddFontFile(Metal.Config.Paths.ThemesFolder + Settings.Instance.GetValue("LastSettings.Theme", "BlackMetal") + "\\" + fontName + ".ttf");

            // Apply font
            this.Font = new System.Drawing.Font(this.pfc.Families[0], fontSize, fontStyle);

            // Fixing if the user changes DPI size:
            this.Height = this.Font.Height;
        }

        private void MetalLabel_MouseDown(object sender, MouseEventArgs e)
        {
            UserControl parent = this.Parent as UserControl;
            if (parent != null)
                BaseForm.FormMove.Instance.Start(e, parent.ParentForm);
            //else
            //    BaseForm.FormMove.Instance.Start(e, this.Parent as Form);
        }

        private void MetalLabel_MouseMove(object sender, MouseEventArgs e)
        {
            UserControl parent = this.Parent as UserControl;
            if (parent != null) // The label is in a user control
                BaseForm.FormMove.Instance.Move(e, parent.ParentForm);
            //else // The label is in a form
            //    BaseForm.FormMove.Instance.Move(e, this.Parent as Form);
        }

        private void MetalLabel_MouseUp(object sender, MouseEventArgs e)
        {
            BaseForm.FormMove.Instance.Stop();
        }
    }
}
